﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;


using CRM.Entity;
using CRM.Entity.Extra;
using CRM.Dictionary.Service;
using CRM.DataAccess;
using CRM.Entity.Page;

namespace CRM.DataService
{
    public partial class News_Detail_DataService
    {
        //对Dictionary的操作类
        News_Detail_DicService dicService;
        //对数据层的操作类
        News_Detail_DataAccess dataAccess;

        public News_Detail_DataService()
        {
            dicService = new News_Detail_DicService();

            dataAccess = new News_Detail_DataAccess();
        }

        public List<News_Detail> GetAll()
        {
            return dicService.News_Detail_List().ListEntity;
        }

        public News_DetailPage GetList(PageInfo page)
        {
            return dicService.News_Detail_List(page);
        }

        public News_DetailPage GetList(Func<News_Detail, bool> func)
        {
            return dicService.News_Detail_List(func);
        }

        public News_DetailPage GetList(PageInfo page, Func<News_Detail, bool> func)
        {
            return dicService.News_Detail_List(page, func);
        }

        public List<News_Detail> GetListTop(int top, Func<News_Detail, bool> func)
        {
            return dicService.News_Detail_List_Top(top, func);
        }

        public News_Detail GetSingle(int News_DetailID)
        {
            return dicService.News_Detail_Single(News_DetailID);
        }

        public News_Detail GetSingleMultiple(Func<News_Detail, bool> func)
        {
            return dicService.News_Detail_Multiple(func);
        }

        public bool Add(News_Detail news_Detail)
        {            
            //先插入数据库
            bool isSuccess = dataAccess.News_Detail_Add(news_Detail);

            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再插入内存
            isSuccess = dicService.News_Detail_Add(news_Detail);

            return isSuccess;
        }
        
        public bool AddBatch(List<News_Detail> list)
        {            
            //先插入数据库
            bool isSuccess = dataAccess.News_Detail_AddBatch(list);
            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再插入内存
            isSuccess = dicService.News_Detail_AddBatch(list);

            return isSuccess;
        }

        public bool Update(News_Detail news_Detail)
        { 
            //先更新数据库
            bool isSuccess = dataAccess.News_Detail_Update(news_Detail);

            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再更新内存
            isSuccess = dicService.News_Detail_Update(news_Detail);

            return isSuccess;
        }
        
        public bool UpdateBatch(List<News_Detail> list)
        {
            //先更新数据库
            bool isSuccess = dataAccess.News_Detail_UpdateBatch(list);

            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再更新内存
            isSuccess = dicService.News_Detail_UpdateBatch(list);

            return isSuccess;
        }

        public bool Delete(News_Detail news_Detail)
        {     
            //先删除数据库
            bool isSuccess = dataAccess.News_Detail_Remove(news_Detail);

            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再删除内存
            isSuccess = dicService.News_Detail_Remove(news_Detail);

            return isSuccess;
        }
    }
}





